﻿using System.Net;
using System.Runtime.Serialization;

namespace Toybox.NicoSharp.Video.RiApi
{
	using RiApiPrimitives;

	public class RelatedVideo : AbstractRiApi
	{

		#region [Static]

		public static RelatedVideo Get(ContentId contentId, CookieCollection cookies = null)
		{
			return Get(contentId.CompleteId, cookies);
		}

		public static RelatedVideo Get(string id, CookieCollection cookies = null)
		{
			if (string.IsNullOrEmpty(id)) return null;

			string url = NicoUrls.RiApi + "watch/relatedvideo";
			return Get<RelatedVideo>(url + "?video_id=" + id, cookies);
		}

		#endregion [Static]


		#region Public Members

		[DataMember]
		public Item[] list;

		#endregion Public Members


		#region [SubClass]

		[DataContract]
		public class Item
		{
			[DataMember]
			public string type;

			[DataMember]
			public string id;

			#region Mylist

			[DataMember]
			public string name;

			[DataMember]
			public string description;

			#endregion Mylist

			#region Video

			[DataMember]
			public string thumbnail_url;

			[DataMember]
			public string length;

			[DataMember]
			public string title;

			[DataMember]
			public int view_counter;

			[DataMember]
			public int num_res;

			[DataMember]
			public int mylist_counter;

			[DataMember]
			public string first_retrieve;

			[DataMember]
			public string description_short;

			#endregion Video

		}

		#endregion [SubClass]

	}
}
